package com.bw.zh32301.register

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils
import com.bw.base.mvvm.BaseActivity
import com.bw.zh32301.R
import com.bw.zh32301.databinding.ActivityRegisterBinding
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = "/app/RegisterActivity")
class RegisterActivity : BaseActivity<ActivityRegisterBinding,UserViewModel>() {
    override fun initView() {
        binding.bt.setOnClickListener {
            viewModel.register(binding.registerPassword.text.toString(),binding.registerUsername.text.toString())
        }
        binding.registerGetCode.setOnClickListener {
            viewModel.code(binding.registerUsername.text.toString())
        }
    }

    override fun initData() {
        viewModel.registerLiveData.observe(this){
            ARouter.getInstance().build("/app/MainActivity2").navigation()
            finish()
        }
        viewModel.codeLiveData.observe(this){
            ToastUtils.showShort(it.content)
        }
    }
}